package com.hualan.servlet;

import com.alibaba.fastjson.JSON;
import com.hualan.dao.CourierStationDao;
import com.hualan.dao.impl.CourierStationDaoImp;
import com.hualan.utils.DBUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@WebServlet(("/updatePcsStatus"))
public class updatePcsStatus extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        CourierStationDao csdao=new CourierStationDaoImp();
        String courierStationId= req.getParameter("courierStationId");
        String courierStationStatus1= req.getParameter("courierStationStatus");
        int courierStationStatus=Integer.parseInt(courierStationStatus1);
        int row = DBUtils.update("update  panghu_courier_station set courier_station_status=? where courier_station_id=?",courierStationStatus,courierStationId);
        Map<String,Object> map=new HashMap<>();
        if (row<1){
            map.put("code",302);
            map.put("message","上架状态修改失败");
        }else {
            map.put("code",200);
            map.put("message","上架状态修改成功！");
        }
        resp.getWriter().write(JSON.toJSONString(map));

    }
}
